import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
import { getUserInfo } from '../api/common'
import adminStore from './module/admin'
import studentStore from './module/student'
import courseStore from './module/course'
import videoStore from './module/video'
export default new Vuex.Store({
  state: {
    userInfo: {},//用户信息
    headFlag: true
  },
  mutations: {
    changeUser (state, userInfo) {
      state.userInfo = userInfo;
    },
    changeHeadFlag (state, flag) {
      state.headFlag = flag;
    }
  },
  actions: {
    async getUserAction ({ commit }) {
      var res = await getUserInfo()
      commit("changeUser", res)
    },
    headFlagAction ({ commit }, flag) { //改变导航栏的显示隐藏actions
      commit("changeHeadFlag", flag)
    }
  },
  getters: {
    headFlag: state => state.headFlag
  },
  modules: {
    adminStore,
    studentStore,
    courseStore,
    videoStore
  }
});
